#!/bin/bash
set -e

echo "📊 查询最近的用户行为分析结果..."
echo ""

docker exec -it browse-etl-postgres psql -U postgres -d behavior_analysis -c "
SELECT 
  id,
  user_id,
  behavior_type,
  behavior_description,
  analysis_method,
  confidence,
  to_char(created_at, 'YYYY-MM-DD HH24:MI:SS') as created_at
FROM user_behaviors 
ORDER BY created_at DESC 
LIMIT 20;
"

echo ""
echo "📈 统计信息："
docker exec -it browse-etl-postgres psql -U postgres -d behavior_analysis -c "
SELECT 
  analysis_method,
  behavior_type,
  COUNT(*) as count,
  ROUND(AVG(confidence)::numeric, 2) as avg_confidence
FROM user_behaviors 
GROUP BY analysis_method, behavior_type
ORDER BY analysis_method, behavior_type;
"
